﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace LibMS
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            //routes.MapRoute(
            //    name: "Default",
            //    url: "{controller}/{action}/{id}",
            //    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            //);

            routes.MapRoute(
                name: "Default",
                url: "",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "",
                url: "FileUpload/FileHandler/{documentId}",
                defaults: new { controller = "FileUpload", action = "FileHandler", documentId = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "",
                url: "Backload/UploadHandler",
                defaults: new { controller = "Backload", action = "UploadHandler" }
            );

            routes.MapRoute(
                name: "",
                url: "backload",
                defaults: new { controller = "BackloadDemo", action = "Index" }
            );

            routes.MapRoute(
                name: "",
                url: "report/regborrow/{bdId}",
                defaults: new { controller = "Report", action = "RegBorrowDocument", bdId = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "",
                url: "documents/new",
                defaults: new { controller = "LibDocuments", action = "ListNew" }
            );

            routes.MapRoute(
                name: "",
                url: "documents-viewcount",
                defaults: new { controller = "LibDocuments", action = "GetByViewCount" }
            );

            routes.MapRoute(
                name: "",
                url: "documents/search1/{search}",
                defaults: new { controller = "LibDocuments", action = "SearchTop10By1Condition", search = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "",
                url: "documents/search2/{search}",
                defaults: new { controller = "LibDocuments", action = "SearchBy1Condition", search = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "",
                url: "documents/detail/{documentId}",
                defaults: new { controller = "LibDocuments", action = "DocumentDetail", documentId = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "",
                url: "documents/category/{categoryId}",
                defaults: new { controller = "LibDocuments", action = "GetByCategory", categoryId = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "",
                url: "documents/{order}",
                defaults: new { controller = "LibDocuments", action = "Index", order = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "",
                url: "documents-upload/{documentId}/{isModal}",
                defaults: new { controller = "LibDocuments", action = "UploadFile", documentId = UrlParameter.Optional, isModal = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "",
                url: "media/{filename}/{ext}",
                defaults: new { controller = "LibDocuments", action = "Streaming", filename = UrlParameter.Optional, ext = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "",
                url: "categories",
                defaults: new { controller = "LibCategories", action = "Index" }
            );

            routes.MapRoute(
                name: "",
                url: "categories/detail/{categoryId}",
                defaults: new { controller = "LibCategories", action = "CategoryDetail", categoryId = UrlParameter.Optional }
            );

            //Admin page
            routes.MapRoute(
                name: "",
                url: "admin/documents",
                defaults: new { controller = "LibDocuments", action = "GetDataForAdmin" }
            );

            routes.MapRoute(
                name: "",
                url: "admin/categories",
                defaults: new { controller = "LibCategories", action = "GetDataForAdmin" }
            );

            routes.MapRoute(
                name: "",
                url: "admin/racks",
                defaults: new { controller = "LibRack", action = "GetDataForAdmin" }
            );

            routes.MapRoute(
                name: "",
                url: "admin/users",
                defaults: new { controller = "LibUser", action = "GetDataForAdmin" }
            );

            routes.MapRoute(
                name: "",
                url: "admin/borrows",
                defaults: new { controller = "LibBorrowDocument", action = "GetDataForAdmin" }
            );
        }
    }
}